# 程序入口
import argparse
import datetime
from config import FMT
from utils.date_tools import build_dates
from api.user_check import UserCheck
from api.date_record import DateRecordApi
from api.check_log import CheckLogCollector

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-s', '--start', type=str, help="开始日期", default="2022-1-1")
    parser.add_argument('-e', '--end', type=str, help='截止日期', default="2022-4-28")
    args = parser.parse_args()
    existence_check_log = DateRecordApi.query_check_log()
    if args.start in "" and args.end in "":
        dates = [(datetime.datetime.now() + datetime.timedelta(days=-1)).strftime(FMT)]
    else:
        dates = build_dates(args.end, args.start, fmt=FMT)
    chc = CheckLogCollector(dates, UserCheck.get_check_user())
    chc.analysis_check_data()
    # L = chc.submit_data()
    # if len(L) > 0:
    #     DateRecordApi.add_check_log(L)
